﻿<UserControl x:Class="Microsoft.ALMRangers.Samples.MyHistory.SummarySectionView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mvvm="clr-namespace:Microsoft.TeamFoundation.MVVM;assembly=Microsoft.TeamFoundation.Controls"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300"
                          DataContext="{Binding RelativeSource={RelativeSource Self}}">
    <UserControl.Resources>
        <ResourceDictionary Source="/Microsoft.ALMRangers.Samples.MyHistory;component/Resources/ResourceDictionary.xaml" />
    </UserControl.Resources>
    <Grid Margin="6,6,6,6">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!-- Search -->
        <WrapPanel Orientation="Horizontal" Grid.Row="0" Margin="0,0,0,6">
            <TextBox Name="TextBoxSearch" KeyUp="TextBoxSearch_KeyUp" Background="#FFEFEFF2" Width="240">
                <TextBox.ToolTip>
                    <TextBlock>Search by User Account or Display name<LineBreak />Press [ENTER] to search.</TextBlock>
                </TextBox.ToolTip>
            </TextBox>
        </WrapPanel>

        <!-- WorkItems -->
        <WrapPanel Orientation="Vertical" Grid.Row="1" Margin="0,0,0,6">
            <TextBlock FontWeight="Bold">Work Items</TextBlock>
            <ListView x:Name="workItemList" ItemsSource="{Binding Path=ParentSection.WorkItems}" BorderThickness="0"
                  SelectionMode="Single" ScrollViewer.HorizontalScrollBarVisibility="Hidden"
                  MouseDoubleClick="WorkItemList_MouseDoubleClick" KeyDown="WorkItemList_KeyDown"
                  mvvm:FrameworkElementBehaviors.IgnoreMouseWheel="True" 
                  ItemContainerStyle="{StaticResource {x:Type ListViewItem}}">
                <ListView.View>
                    <GridView>
                        <GridView.ColumnHeaderContainerStyle>
                            <Style>
                                <Setter Property="FrameworkElement.Visibility" Value="Collapsed"/>
                            </Style>
                        </GridView.ColumnHeaderContainerStyle>
                        <GridViewColumn>
                            <GridViewColumnHeader Content="Work Item"/>
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Path=Id}"/>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                        <GridViewColumn Width="500">
                            <GridViewColumnHeader Content="Title"/>
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Path=Title}"/>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                    </GridView>
                </ListView.View>
            </ListView>
        </WrapPanel>

        <!-- Changesets -->
        <WrapPanel Orientation="Vertical" Grid.Row="2" Margin="0,0,0,6">
            <TextBlock FontWeight="Bold"><Hyperlink x:Name="historyLink" Click="HistoryLink_Click">Changesets</Hyperlink></TextBlock>
            <ListView x:Name="changesetList" ItemsSource="{Binding Path=ParentSection.Changesets}" BorderThickness="0"
                  SelectionMode="Single" ScrollViewer.HorizontalScrollBarVisibility="Hidden"
                  mvvm:FrameworkElementBehaviors.IgnoreMouseWheel="True"  
                  MouseDoubleClick="ChangesetList_MouseDoubleClick" KeyDown="ChangesetList_KeyDown">
                <ListView.View>
                    <GridView>
                        <GridView.ColumnHeaderContainerStyle>
                            <Style>
                                <Setter Property="FrameworkElement.Visibility" Value="Collapsed"/>
                            </Style>
                        </GridView.ColumnHeaderContainerStyle>
                        <GridViewColumn>
                            <GridViewColumnHeader Content="Changeset"/>
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Path=ChangesetId}"/>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                        <GridViewColumn Width="500">
                            <GridViewColumnHeader Content="Comment"/>
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Path=Comment, Converter={StaticResource ChangesetCommentConverter}}"/>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                    </GridView>
                </ListView.View>
                <ListView.ItemContainerStyle>
                    <Style TargetType="{x:Type ListViewItem}" BasedOn="{StaticResource {x:Type ListViewItem}}">
                        <Setter Property="ToolTip">
                            <Setter.Value>
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                    </Grid.RowDefinitions>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="*"/>
                                    </Grid.ColumnDefinitions>

                                    <TextBlock Grid.Row="0" Grid.Column="0" Margin="0,0,6,3" Text="Changeset ID:" FontWeight="Bold"/>
                                    <TextBlock Grid.Row="0" Grid.Column="1" Margin="0,0,0,3" Text="{Binding Path=ChangesetId}"/>

                                    <TextBlock Grid.Row="2" Grid.Column="0" Margin="0,0,6,3" Text="Date:" FontWeight="Bold"/>
                                    <TextBlock Grid.Row="2" Grid.Column="1" Margin="0,0,0,3" Text="{Binding Path=CreationDate}"/>

                                    <TextBlock Grid.Row="3" Grid.Column="0" Margin="0,0,6,3" Text="Comment:" FontWeight="Bold"/>
                                    <TextBlock Grid.Row="3" Grid.Column="1" Margin="0,0,0,3" Text="{Binding Path=Comment}" TextWrapping="Wrap" MaxWidth="500"/>
                                </Grid>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </ListView.ItemContainerStyle>
            </ListView>
        </WrapPanel>

        <!-- Shelvesets -->
        <WrapPanel Orientation="Vertical" Grid.Row="3" Margin="0,0,0,6">
            <TextBlock FontWeight="Bold">Shelvesets</TextBlock>
            <ListView x:Name="ListViewShelvesets" ItemsSource="{Binding Path=ParentSection.Shelvesets}" BorderThickness="0"
                  SelectionMode="Single" ScrollViewer.HorizontalScrollBarVisibility="Hidden" 
                  MouseDoubleClick="ListViewShelvesets_MouseDoubleClick"  
                  KeyDown="ListViewShelvesets_KeyDown"
                  mvvm:FrameworkElementBehaviors.IgnoreMouseWheel="True" >
                <ListView.View>
                    <GridView>
                        <GridView.ColumnHeaderContainerStyle>
                            <Style>
                                <Setter Property="FrameworkElement.Visibility" Value="Collapsed"/>
                            </Style>
                        </GridView.ColumnHeaderContainerStyle>
                        <GridViewColumn Width="500">
                            <GridViewColumnHeader Content="Shelveset"/>
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Path=Name}"/>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                    </GridView>
                </ListView.View>
                <ListView.ItemContainerStyle>
                    <Style TargetType="{x:Type ListViewItem}" BasedOn="{StaticResource {x:Type ListViewItem}}">
                        <Setter Property="ToolTip">
                            <Setter.Value>
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                    </Grid.RowDefinitions>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="*"/>
                                    </Grid.ColumnDefinitions>
                                    <TextBlock Grid.Row="0" Grid.Column="0" Margin="0,0,6,3" Text="Creation Date:" FontWeight="Bold"/>
                                    <TextBlock Grid.Row="0" Grid.Column="1" Margin="0,0,0,3" Text="{Binding Path=CreationDate}"/>
                                    <TextBlock Grid.Row="1" Grid.Column="0" Margin="0,0,6,3" Text="Comment:" FontWeight="Bold"/>
                                    <TextBlock Grid.Row="1" Grid.Column="1" Margin="0,0,0,3" Text="{Binding Path=Comment}"/>
                                </Grid>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </ListView.ItemContainerStyle>
            </ListView>
        </WrapPanel>
    </Grid>
</UserControl>
